package com.ambition.mallchat.common.websocket.domain.enums;

import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @program: mallchat-learnning
 * @ClassName WSReqTypeEnum
 * @description:
 * @author: oldTea
 * @create: 2023-10-14 15:04
 * @Version 1.0
 **/
@AllArgsConstructor
@Getter
public enum WSReqTypeEnum {
    LOGIN(1, "请求登录二维码"),
    HEARTBEAT(2, "心跳包"),
    AUTHORIZE(3, "登录认证"),
    ;

    private final Integer type;

    private final String desc;

    private static Map<Integer,WSReqTypeEnum> cache;

    static {
        cache = Arrays.stream(WSReqTypeEnum.values()).collect(Collectors.toMap(WSReqTypeEnum::getType, Function.identity()));
    }
    public static WSReqTypeEnum of(Integer type){
        return cache.get(type);
    }
}
